package com.tamtamy.jtta.data.xml;

import org.w3c.dom.Document;

import com.tamtamy.jtta.data.ContentFile;
import com.tamtamy.jtta.utility.XMLUtility;

public class XMLContentFile extends ContentFile {
	
	private static final long serialVersionUID = -5100405857921281257L;

	public XMLContentFile(Document xmlDocument) {
		super();
		this.id = Long.parseLong(XMLUtility.getString(xmlDocument, "id"));
		this.title = XMLUtility.getString(xmlDocument, "title");
		this.description = XMLUtility.getString(xmlDocument, "description");
		this.creationDate = XMLUtility.getDate(xmlDocument, "creationDate");
		this.userID = XMLUtility.getString(xmlDocument, "userID");
		this.languageCode = XMLUtility.getString(xmlDocument, "languageCode");
		this.network = XMLUtility.getString(xmlDocument, "network");
		this.permission = XMLUtility.getString(xmlDocument, "permission");
		this.discussionPermission = XMLUtility.getString(xmlDocument, "discussionPermission");
		this.updateDate = XMLUtility.getDate(xmlDocument, "updateDate");
		this.favouriteCounter = XMLUtility.getString(xmlDocument, "favouriteCounter");
		this.highlight = XMLUtility.getString(xmlDocument, "highlight");
		this.numberOfComments = XMLUtility.getString(xmlDocument, "numberOfComments");
		this.tags =  XMLUtility.getStringList(xmlDocument,"tagList", "string");
		this.rate = XMLUtility.getString(xmlDocument, "rate");
		this.ratesNumber = XMLUtility.getString(xmlDocument, "ratesNumber");
		this.commentList = XMLUtility.getStringList(xmlDocument,"commentsList", "long");
		this.views = XMLUtility.getString(xmlDocument, "views");
		this.downloads = XMLUtility.getString(xmlDocument, "downloads");
		this.size = XMLUtility.getString(xmlDocument, "size");
		this.contentUrl = XMLUtility.getString(xmlDocument, "contentUrl");
		this.contentFileName = XMLUtility.getString(xmlDocument, "contentFileName");
		this.thumbnailPresent = Boolean.parseBoolean(XMLUtility.getString(xmlDocument, "thumbnailPresent"));
		this.thumbnailSmall = XMLUtility.getString(xmlDocument, "thumbnailSmall");
		this.thumbnailRect = XMLUtility.getString(xmlDocument, "thumbnailRect");
		this.thumbnailMedium = XMLUtility.getString(xmlDocument, "thumbnailMedium");
		this.thumbnailOriginal = XMLUtility.getString(xmlDocument, "thumbnailOriginal");
		this.contentType = XMLUtility.getString(xmlDocument, "contentType");
		this.contentTypeCategory = XMLUtility.getString(xmlDocument, "contentTypeCategory");
		this.descriptionPlainText = XMLUtility.getString(xmlDocument, "descriptionPlainText");
		this.permalink = XMLUtility.getString(xmlDocument, "permalink");
	}

}
